package jsen.tool.ddd.demo.application;

import jsen.tool.ddd.adapter.event.common.EventBus;
import jsen.tool.ddd.demo.domain.parking.ParkingLot;
import jsen.tool.ddd.demo.domain.parking.factory.ParkingLotFactory;

import java.util.concurrent.Executors;

/**
 * @author jsen
 * @date 2021/9/30
 */
public class ParkingLotManageSystem {

    public void start() {
        ParkingLot parkingLot = ParkingLotFactory.build();
        parkingLot.startParkingLot(new EventBus(Executors.newFixedThreadPool(2)));

        new Thread(() -> {
            while (true) {
                System.out.println(parkingLot.currentStatus());
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

    public static void main(String[] args) {
        ParkingLotManageSystem system = new ParkingLotManageSystem();
        system.start();
    }
}
